package com.bittech.facerecognition.web;

import com.bittech.facerecognition.model.Response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Author: secondriver
 * Created: 2019/5/28
 */
@WebServlet(urlPatterns = {"/match"})
public class MatchFaceServlet extends ImageBaseServlet {
    
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        byte[] imageLeft = readImage(req, "left");
        byte[] imageRight = readImage(req, "right");
        Double score = this.faceAiClient.match(imageLeft, imageRight);
        responseJSON(resp, Response.ofOk(score.intValue()));
    }
}
